package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;


public class ForgetPswTask extends CouponHttpBaseTask {

    private String mPhone;
    private String mPwd;
    private String mCode;
    private static final String PHONE = "phoneNum";
    private static final String PWD = "pwd";
    private static final String VFCODE = "vfCode";

    public ForgetPswTask(String phone, String pwd, String code) {
        super(TaskType.FORGET_PSW_TASK);
        mPhone = phone;
        mPwd = pwd;
        mCode = code;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.FORGET_PSW_REQUEST);
            JSONObject json = new JSONObject();
            json.put(PHONE, mPhone);
            json.put(PWD, mPwd);
            json.put(VFCODE, mCode);
            request.setData(json.toString());
            request.setApiNo(ApiNo.FORGET_PSW);
            addRequest(request);
        }
    }


}
